package pers.vic.upload.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * 描述: 一些通用的配置
 * @author Vic.xu
 * @date 2022-09-22 9:47
 */
@Configuration
public class CommonWebMvcConfigurer implements WebMvcConfigurer{


    /**
     * 跨域设置
     * @param registry CorsRegistry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowCredentials(true)
                .exposedHeaders("*")
                //.exposedHeaders("Set-Cookie")
                .allowedOriginPatterns("*")
                .allowedHeaders("*")
                .allowedMethods("*")
                .maxAge(7200);
    }
}
